package com.example.deepai.model;

import jakarta.persistence.*;
import lombok.Data;
import java.time.LocalDateTime;

@Data
@Entity
@Table(name = "chat_sessions")
public class ChatSession {
    @Id
    private String sessionId;
    
    @Column(length = 1000)  // 增加标题长度限制
    private String title;
    
    @Column(name = "create_time")
    private LocalDateTime createTime;
    
    @Column(name = "last_message_time")
    private LocalDateTime lastMessageTime;
    
    @PrePersist
    public void prePersist() {
        if (createTime == null) {
            createTime = LocalDateTime.now();
        }
        if (lastMessageTime == null) {
            lastMessageTime = createTime;
        }
    }
}